package com.chuangjiangx.member.score.ddd.domain.model;


import com.chuangjiangx.dddbase.Entity;
import com.chuangjiangx.member.basic.ddd.domain.model.MbrScoreGiftRuleHisId;
import com.chuangjiangx.member.basic.ddd.domain.model.MbrScoreGiftRuleId;
import com.chuangjiangx.member.basic.ddd.domain.model.MerchantId;
import com.chuangjiangx.member.score.ddd.domain.model.MbrScoreGiftRuleScope;
import com.chuangjiangx.domain.shared.model.Enable;
import lombok.Getter;

import java.util.Date;

/**
 * 积分兑换规则记录
 * Created by YangKuo on 2018/1/23.
 */
@Getter
public class MbrScoreGiftRuleHis extends Entity<MbrScoreGiftRuleHisId> {

    /**
     * 积分兑换规则id
     */
    private MbrScoreGiftRuleId mbrScoreGiftRuleId;

    /**
     * 兑换规则名称
     */
    private String name;

    /**
     * 兑换条件
     */
    private Long score;

    /**
     * 商品名称
     */
    private String goodsName;

    /**
     * 规则对象
     */
    private MbrScoreGiftRuleScope scope;

    /**
     * 是否启用
     */
    private Enable enable;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 商户id
     */
    private MerchantId merchantId;

    /**
     * 图片地址
     */
    private String imageUrl;

    /**
     * 兑换次数
     */
    private Long count;

    /**
     * 数据库对象
     *
     * @param mbrScoreGiftRuleHisId 积分兑换记录id
     * @param mbrScoreGiftRuleId    兑换规则id
     * @param name                  兑换规则名称
     * @param score                 兑换条件
     * @param goodsName             商品名称
     * @param scope                 规则对象
     * @param enable                是否启用
     * @param createTime            创建时间
     * @param merchantId            商户id
     * @param imageUrl              图片地址
     * @param count                 兑换数量
     */
    public MbrScoreGiftRuleHis(MbrScoreGiftRuleHisId mbrScoreGiftRuleHisId, MbrScoreGiftRuleId mbrScoreGiftRuleId,
                               String name, Long score, String goodsName, MbrScoreGiftRuleScope scope, Enable enable, Date createTime, MerchantId merchantId,
                               String imageUrl, Long count) {
        setId(mbrScoreGiftRuleHisId);
        this.mbrScoreGiftRuleId = mbrScoreGiftRuleId;
        this.name = name;
        this.score = score;
        this.goodsName = goodsName;
        this.scope = scope;
        this.enable = enable;
        this.createTime = createTime;
        this.merchantId = merchantId;
        this.imageUrl = imageUrl;
        this.count = count;
    }

    /**
     * 添加记录
     */
    public MbrScoreGiftRuleHis(MbrScoreGiftRuleId mbrScoreGiftRuleId, Long score, String goodsName,
                               MerchantId merchantId, String imageUrl, Long count) {
        this.mbrScoreGiftRuleId = mbrScoreGiftRuleId;
        this.name = score + "积分兑换商品" + goodsName;
        this.score = score;
        this.goodsName = goodsName;
        this.scope = MbrScoreGiftRuleScope.ALL;
        this.enable = Enable.ENABLE;
        this.createTime = new Date();
        this.merchantId = merchantId;
        this.imageUrl = imageUrl;
        this.count = count;
    }

}
